import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { routes, RouteRaw } from './routes'

const routerView = (routes: RouteRaw[]) => {
	return (
		<>
			{
				routes.map((v, i) => {
					return <Route path={v.path} element={<v.element></v.element>} key={i}>
						{
							v.children && routerView(v.children)
						}
					</Route>
				})
			}
		</>
	)
}


const Router = () => {
	return (
		<BrowserRouter>
			<Routes>
				{
					routerView(routes)
				}
			</Routes>
		</BrowserRouter>
	)
}


export default Router